package com.tdam2011.grupo03.activitys;

import com.tdam2011.grupo03.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;

public class PickDate extends Activity implements OnClickListener {
	private DatePicker datePicker;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.datepicker);
		Button btnGuardar = (Button) findViewById(R.id.btnGuardar);
		btnGuardar.setOnClickListener(this);
		datePicker = (DatePicker) findViewById(R.id.datePicker);
	}

	@Override
	public void onClick(View v) {
		Intent intent = new Intent();
		String selectedDate = datePicker.getDayOfMonth() + "/"
				+ (datePicker.getMonth() + 1) + "/" + datePicker.getYear();
		int caller = getIntent().getExtras().getInt("caller");
		intent.putExtra("date", selectedDate);
		setResult(caller, intent);
		finish();
	}
}
